const { RESPONSE_SUCCESS_CODE, RESPONSE_SUCCESS_MSG } = require('../../constant/rest');

class ApiRes {
  constructor(code, data, message = RESPONSE_SUCCESS_MSG) {
    this.code = code;
    this.data = data;
    this.message = message;
  }

  static success(data, message = RESPONSE_SUCCESS_MSG) {
    return new ApiRes(RESPONSE_SUCCESS_CODE, data, message);
  }

  static ok() {
    return new ApiRes(RESPONSE_SUCCESS_CODE, null, RESPONSE_SUCCESS_MSG);
  }

  static error(code, message) {
    return new ApiRes(code, null, message);
  }

  static custom(code, data, message) {
    return new ApiRes(code, data, message);
  }
}

module.exports = ApiRes;
